home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / dev / e / FR-Modules.readme < prev    next >
Encoding:
Text File  |  2000-07-01  |  6.8 KB  |  251 lines

  1. Short:    FASTEST FGets() replacement, quick sort, hex view, ansi2text, SetFunction() modules
  2. Author:   fredinou@bigfoot.com (FR)
  3. Type:     dev/e
  4. Requires: kickstart 2.0+
  5.  
  6. Here are some modules I made 2 years ago for my own programs.
  7.  
  8. summary
  9. ~~~~~~~
  10. FGets() AmigaDOS replacement (about 5 times faster)
  11. Quick sort (for sorting arrays and make fast sort programs)
  12. Hex view (to view better binary files)
  13. Ansi to text (removes escape sequences)
  14. SetFunction() AmigaDOS replacement (SetFunction object)
  15. CON window size (How many lines of text it may contain)
  16. strtok() equivalent (like the C function)
  17. Me
  18. It's freeware
  19. Quit
  20. ============================================================================
  21. readline()
  22. ----------------------------------------------------------------------------
  23. Synopsis:
  24.  
  25. Replaces the AmigaDOS FGets() function.
  26. About 5 times faster.
  27. About 30 times faster than the ReadStr E function.
  28.  
  29. readline(object)
  30. readlinefrom(filehandle)
  31. endrealine(object)
  32.  
  33. You don't need to know what object is. It's a pointer to something and
  34. is just used for the endreadline() function.
  35. You get the line read with ^o.
  36.  
  37. Example :
  38.  
  39.   DEF fh,o,buf[256]:STRING,i
  40.   IF fh:=Open('xpke.e',OLDFILE)
  41.     o:=readlinefrom(fh)
  42.     WHILE readline(o)
  43.       printF("\s\n", ^o)
  44.     ENDWHILE
  45.     endreadline(o)
  46.     Close(fh)
  47.   ENDIF
  48. ============================================================================
  49. insertinorder()
  50. ----------------------------------------------------------------------------
  51. Synopsis:
  52.  
  53. Insert an element in a sorted array using quick sort algorithm.
  54.  
  55. insertinorder(arrayptr,len,element,comparisonfunction,userdata)
  56.  
  57. arrayptr : pointer to an array
  58.            the array may be empty but allocated.
  59. len : length of the array
  60. element : pointer to the element to insert in the array
  61. comparisonfunction : pointer to your function of comparison
  62. userdata : parameters of the comparison function
  63.  
  64. comparison function :
  65. cmpfunction(element, newelement, userdata : PTR TO LONG)
  66.  
  67. return TRUE if element and newelement are comparable.
  68. newelement is the element to insert which you compare with an ordinary
  69. element of your array.
  70. ============================================================================
  71. hex()
  72. ----------------------------------------------------------------------------
  73. Synopsis:
  74.  
  75. Display a binary string in hex view form.
  76.  
  77. hex(estring,binstring,len)
  78.  
  79. estring : returned hex view string
  80. binstring : binary data in memory
  81. len : length of binary data
  82.  
  83. Example of view:
  84.  
  85. 464F524D 00000046 50524546 50524844    FORM...FPREFPRHD
  86. 00000006 00000000 0000494E 50540000    ..........INPT..
  87. 002C6600 61310000 00000000 00000000    .,f.a1..........
  88. 00000001 00000001 0007A120 00000000    ..........ยก ....
  89. ============================================================================
  90. noansi()
  91. ----------------------------------------------------------------------------
  92. Synopsis:
  93.  
  94. Removes the escape sequences from string.
  95.  
  96. noansi(string)
  97.  
  98. Example:
  99. Strcopy(str, "\e[33mtext\e[31m")
  100. noansi(str)
  101. PrintF(str)
  102.  
  103. Output:
  104. text
  105. ============================================================================
  106. nblineswin()
  107. ----------------------------------------------------------------------------
  108. Synopsis:
  109.  
  110. Returns the number of lines of text displayable on the window.
  111.  
  112. nblineswin(PTR TO window)
  113.  
  114. ============================================================================
  115. setf()
  116. ----------------------------------------------------------------------------
  117. Synopsis:
  118.  
  119. SetFunction() object in E.
  120.  
  121. setf(libbase,offset,newfunc)
  122.  
  123. Constructor.
  124. libbase : pointer to library
  125. offset : offset of the function to patch (See asm includes).
  126. newfunc : pointer to the new function for replacement.
  127.  
  128. enabled()
  129.  
  130. Returns TRUE is patch is enabled.
  131.  
  132. disable()
  133.  
  134. Disables the patch.
  135.  
  136. enable()
  137.  
  138. Reenables the patch.
  139.  
  140. patched()
  141.  
  142. Returns TRUE is the function has been patched by another process.
  143.  
  144. end()
  145.  
  146. Destructor.
  147.  
  148. oldfunc()
  149.  
  150. Returns the pointer to the old function.
  151.  
  152. Example:
  153. #define OFFSET -30 (Open)
  154. #define BASE dosbase
  155.  
  156. MODULE 'tools/geta4'
  157.  
  158. PROC main()
  159.   NEW setf.setf(BASE,OFFSET,{new})
  160.   storea4()
  161.   WHILE CtrlC()<>TRUE DO Delay(10)
  162.   IF setf.attemptend()=FALSE THEN WriteF('Someone patched your function\n')
  163.   WHILE setf.attemptend()=FALSE DO Delay(10)
  164.   END setf
  165. ENDPROC
  166.  
  167. PROC new()
  168.   DEF name,mode,fh
  169.   MOVE.L D1,name
  170.   MOVE.L D2,mode
  171.   geta4()
  172.   WriteF('\s opened with mode \s\n',name,IF mode=NEWFILE THEN 'NEWFILE' ELSE 'OLDFILE')  MOVE.L name,D1
  173.   MOVE.L mode,D2
  174.   fh:=setf.oldfunc()
  175.   WriteF('fh: \d\n',fh)
  176. ENDPROC fh
  177. ============================================================================
  178. readtoken()
  179. ----------------------------------------------------------------------------
  180. Synopsis:
  181.  
  182. strtok() equivalent.
  183.  
  184. readtokenfrom(string,separators=NIL,oneonly=FALSE)
  185.  
  186. constructor
  187.  
  188. string : a string
  189. separators : a string of separators
  190. oneonly : treat subsequent separators as one separator
  191.  
  192. readtoken(o)
  193.  
  194. return the next token
  195.  
  196. endreadtoken(o)
  197.  
  198. destructor
  199.  
  200. nbtoken(o)
  201.  
  202. returns the number of tokens in the string
  203.  
  204. Example:
  205.  
  206. DEF o
  207.  
  208. o := readtokenfrom("token1;token2;token3.token4", ".;")
  209. WHILE readtoken(o)
  210.   PrintF("%s\n", ^o)
  211. ENDWHILE
  212. endreadtoken(o)
  213. ============================================================================
  214. Talking about me ...
  215. ----------------------------------------------------------------------------
  216. There was 2 years I made these proggies and never take the time to spread
  217. it. So here it is for your convenience. Hope you will use it.
  218.  
  219. You may reach me by email if u want.
  220.  
  221. fredinou@bigfoot.com
  222. ============================================================================
  223. Legal stuff
  224. ----------------------------------------------------------------------------
  225. These modules and source are freeware. Do whatever you want with it.
  226.  
  227. This program is distributed in the hope that it will be useful,
  228. but WITHOUT ANY WARRANTY; without even the implied warranty of
  229. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  230. ============================================================================
  231.  
  232.  
  233. ============================= Archive contents =============================
  234.  
  235. Original  Packed Ratio    Date     Time    Name
  236. -------- ------- ----- --------- --------  -------------
  237.      351     249 29.0% 01-Oct-97 19:25:42  ansi.e
  238.     2962    1334 54.9% 04-Oct-97 04:31:50  boyer.e
  239.      248     179 27.8% 26-Sep-97 22:13:38  geta4.e
  240.      542     333 38.5% 04-Oct-97 03:03:04  hex.e
  241.      748     372 50.2% 04-Oct-97 03:20:36  insertinorder.e
  242.     5073    2261 55.4% 20-May-99 20:17:58  Modules.guide
  243.      263     202 23.1% 04-Oct-97 02:49:18  nblineswin.e
  244.     2014     837 58.4% 04-Oct-97 04:04:46  readline.e
  245.     1308     552 57.7% 04-Oct-97 04:06:30  readlinetest.e
  246.     1751     650 62.8% 16-Nov-97 17:55:16  readtoken.e
  247.      920     371 59.6% 26-Sep-97 22:13:42  setf.e
  248.     1222     547 55.2% 15-Jun-97 16:48:44  setftest.e
  249. -------- ------- ----- --------- --------
  250.    17402    7887 54.6% 26-Jun-100 07:32:22   12 files
  251.